import time

from selenium import webdriver
from selenium.webdriver.common.by import By

driver=webdriver.Firefox()
driver.get('http://10.59.9.12:7001/')
driver.maximize_window()
time.sleep(3)
#点击去登录
driver.find_element(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a').click()
time.sleep(3)
#获取元素文字
# wz=driver.find_element(By.LINK_TEXT,'登录')
# wz.click()
# print(wz)
#输入框输入
driver.find_element(By.NAME,'username').send_keys('13811033962')
time.sleep(3)
#密码框输入
driver.find_element(By.NAME,'password').send_keys('123456')
time.sleep(10)
#点击登录按钮
driver.find_element(By.CLASS_NAME,'finish-btn').click()
time.sleep(3)
#切换页面
driver.switch_to.window(driver.window_handles[-1])
time.sleep(5)
#隐式等待
driver.implicitly_wait(10)
#搜索框搜索
driver.find_element(By.XPATH,'//*[@id="searchForm"]/div[1]/input').send_keys('音乐耳机')
time.sleep(3)
#点击搜索按钮
driver.find_element(By.XPATH,'//*[@id="searchForm"]/div[2]/input').click()
time.sleep(5)
#进入商品详情
driver.find_element(By.XPATH,'/html/body/div[5]/div[2]/div[2]/div[1]/ul/li/div[1]/span/a/img').click()
time.sleep(5)
#清空元素
qk=driver.find_element(By.ID,'store_nums')
qk.clear()
qk.send_keys('5')
time.sleep(3)
